package com.ai.dmc.index.common.bean;

import java.io.Serializable;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;

import com.ai.dmc.index.common.util.DateUtil;
import com.ai.dmc.index.common.InitParam;

public class StaffSessBean
		implements HttpSessionBindingListener, Serializable {
	private static final long serialVersionUID = 2317127679778839123L;
	private String userId = "";
	private String userName = "";
	private String userPassword = "";
	private String areaId = "";

	private String email = "";

	// 手机号码
	private String phone = "";
	private String status = "";

	private String jobId = "";
	private String jobName = "";

	private String ip = "";
	private String mac = "";
	private String logId = "";

	private String loginTime = "";
	private String loginCount = "";

	// 身份证号
	private String idCardNo = "";

	private String visitFrom = "";

	public String getIdCardNo() {
		return idCardNo;
	}

	public void setIdCardNo(String idCardNo) {
		this.idCardNo = idCardNo;
	}

	public String getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(String loginTime) {
		this.loginTime = loginTime;
	}

	public String getLoginCount() {
		return loginCount;
	}

	public void setLoginCount(String loginCount) {
		this.loginCount = loginCount;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getMac() {
		return mac;
	}

	public void setMac(String mac) {
		this.mac = mac;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getJobId() {
		return jobId;
	}

	public void setJobId(String jobId) {
		this.jobId = jobId;
	}

	public String getJobName() {
		return jobName;
	}

	public void setJobName(String jobName) {
		this.jobName = jobName;
	}

	public Object getAttribute(String arg0) {
		return null;
	}

	public HttpSession getHttpSession() {
		return null;
	}

	public String getLogId() {
		return logId;
	}

	public void setLogId(String logId) {
		this.logId = logId;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getAreaId() {
		return areaId;
	}

	public void setAreaId(String areaId) {
		this.areaId = areaId;
	}

	public void setAttribute(String arg0, Object arg1) {

	}

	public void setHttpSession(HttpSession arg0) {

	}

	public void valueBound(HttpSessionBindingEvent arg0) {
		InitParam.LOGINUSERSESSION.put(this.getUserId(), this);

		String time = DateUtil.getInstance().getToday("yyyy-MM-dd HH:mm:ss");
		System.out.println(
				time + " 当前在线人数：" + InitParam.LOGINUSERSESSION.size() + "人");
	}

	public void valueUnbound(HttpSessionBindingEvent arg0) {
		InitParam.LOGINUSERSESSION.remove(this.getUserId());

		String time = DateUtil.getInstance().getToday("yyyy-MM-dd HH:mm:ss");
		System.out.println(
				time + " 当前在线人数：" + InitParam.LOGINUSERSESSION.size() + "人");
	}

	/**
	 * 判断是否是管理员
	 */
	public Boolean isAdmin() {
		if (jobId.indexOf(InitParam.ADMIN_JOB_ID + ";") != -1) {
			return true;
		}

		return false;
	}

	public String getVisitFrom() {
		return visitFrom;
	}

	public void setVisitFrom(String visitFrom) {
		this.visitFrom = visitFrom;
	}
}
